package com.cyj.mapper.service.impl;

import com.cyj.mapper.entity.Employee;
import com.cyj.mapper.mappers.EmployeeMapper;
import com.cyj.mapper.service.EmployeeService;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @description:
 * @Author C_Y_J
 * @create 2021-03-12 16:27
 **/
@Service
public class EmployeeServiceImpl implements EmployeeService {

    private final EmployeeMapper employeeMapper;

    public EmployeeServiceImpl(EmployeeMapper employeeMapper) {
        this.employeeMapper = employeeMapper;
    }

    @Override
    public Employee getOne(Employee employeeQueryCondition) {

        return employeeMapper.selectOne(employeeQueryCondition);
    }

    @Override
    public Employee getEmployeeById(Integer empId) {
        return employeeMapper.selectByPrimaryKey(empId);
    }

    @Override
    public boolean isExists(Integer empId) {
        return employeeMapper.existsWithPrimaryKey(empId);
    }

    @Override
    public void saveEmployee(Employee employee) {
        employeeMapper.insert(employee);
    }

    @Override
    public void saveEmployeeSelective(Employee employee) {
        employeeMapper.insertSelective(employee);
    }

    @Override
    public void updateEmployeeSelective(Employee employee) {
        employeeMapper.updateByPrimaryKeySelective(employee);
    }

    @Override
    public void removeEmployee(Employee employee) {
        employeeMapper.delete(employee);
    }

    @Override
    public void removeEmployeeById(Integer empId) {
        employeeMapper.deleteByPrimaryKey(empId);
    }

    @Override
    public List<Employee> getEmpListByExample(Example example) {
        return employeeMapper.selectByExample(example);
    }

    @Override
    public List<Employee> getEmpListByRowBounds(RowBounds rowBounds) {
        return employeeMapper.selectByRowBounds(null, rowBounds);
    }
}
